package com.qzdsoft.vo;

import java.util.ArrayList;
import java.util.List;

public class Page<T> {
	private List<T> data = new ArrayList<>();
	private long iTotalDisplayRecords;//实际的总行数,和iTotalRecords保持一致即可
	private long iTotalRecords;//实际的总行数
	private String sEcho;
	private PageRequest pageRequest;
	private long total;

	public Page( List<T> data, long iTotalDisplayRecords,String sEcho,PageRequest pageRequest) {
		this.data = data;
		this.iTotalDisplayRecords = iTotalDisplayRecords;
		this.iTotalRecords = iTotalDisplayRecords;
		this.sEcho = sEcho;
		this.pageRequest = pageRequest;
		this.total = iTotalDisplayRecords;
	}
	public long getTotal(){
		return total;
	}
	public List<T> getData() {
		return data;
	}

	public long getiTotalDisplayRecords() {
		return iTotalDisplayRecords;
	}

	public long getiTotalRecords() {
		return iTotalRecords;
	}

	public String getsEcho() {
		return sEcho;
	}

	public int getCurrentPage(){
		return pageRequest.getPage();
	}

	public int getPageSize() {
		return pageRequest.getPageSize();
	}

	public int getTotalPage() {
		return getPageSize() == 0 ? 1 : (int) Math.ceil((double) total / (double) getPageSize());
	}
}
